package com.example.lock.独占锁;

public class ReadWriteLockDemo {

    public static void main(String[] args) throws Exception{
        Cache cache = new Cache();

        for(int i=1;i<=5;i++){
            final int tempInt = i;
            new Thread(()->{
                cache.put(tempInt+"",tempInt+"");
            },String.valueOf(i)+"-write").start();
        }

        for(int i=1;i<=5;i++){
            final int tempInt = i;
            new Thread(()->{
                cache.get(tempInt+"");
            },String.valueOf(i)+"-read").start();
        }

        cache.put("test","测试");
    }
}
